package com.zzb.framework.role.dao;

import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.google.common.collect.Lists;
import com.zzb.framework.common.BaseDAO;
import com.zzb.framework.role.dao.mapper.SysMenuMapper;
import com.zzb.framework.role.entity.SysMenu;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * 菜单表 Dao接口
 */
@Repository
public class SysMenuDAO extends BaseDAO<SysMenu> {
    @Autowired
    private SysMenuMapper sysMenuMapper;

    public List<SysMenu> listByUserId(String userId) {
        return sysMenuMapper.listByUserId(userId);
    }

    public List<SysMenu> listByRoleId(String roleId) {
        return sysMenuMapper.listByRoleId(roleId);
    }

    public List<SysMenu> listOrderByMenuLevelAscMenuOrderAsc() {
        return sysMenuMapper.selectList(new EntityWrapper<SysMenu>()
                .orderAsc(Lists.newArrayList("menu_level", "menu_order")));
    }

    @Override
    public SysMenuMapper getMapper() {
        return sysMenuMapper;
    }
}
